﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PiscoSourWeb.Models;
using PiscoSourDominio; 

namespace PiscoSourWeb.Controllers
{
    public class OrdenController : Controller
    {  
       private OrdenWS.OrdenesClient OrdenWS = new OrdenWS.OrdenesClient(); 
        
       public ActionResult Register(int id) 
        {
            var datos = new ModelOrden().ListarOrdenes();
            ViewBag.vchObservacion = new SelectList(datos, "vchObservacion", "vchObservacion"); 
            return View();
        }

       [HttpPost]
       public ActionResult Register(Orden objOrden)   
       {
           if (ModelState.IsValid)
           {
               OrdenWS.InsertarOrden(objOrden);  
               return RedirectToAction("List"); 
           }

           var datos = new ModelOrden().ListarOrdenes();     
           ViewData.Model = objOrden;
           ViewBag.vchObservacion = new SelectList(datos, "vchObservacion", "vchObservacion", objOrden.vchObservacion);
           return View();   
       }

        public ActionResult List()  
        {
            ViewBag.test = "Listado de PreOrdenes";  
            var list = new ModelOrden().ListarOrdenes(); 
            return View(list); 
        }

    }
}
